<?php
namespace Home\Controller;
use Think\Controller;
class SubscribeController extends Controller {
  public function index(){
      $this->assign('userid',I(userid));
      $this->assign('gameid',I(gameid));
      $this->assign('title',urldecode(I(title)));
      $this->assign('time',urldecode(I(time)));      
      $this->display();
  }

   public function show(){
      $this->assign('userid',I(userid));
      $this->assign('gameid',I(gameid));
      $this->assign('title',urldecode(I(title)));
      $this->assign('time',urldecode(I(time)));      
      $this->display();

  }
    
   public function book(){
       $mysql =new \SaeMysql();
       if (I(ok)==1) {
            $sql = "SELECT * FROM `WX_subscribe` WHERE `keyid`='".md5(I(gameid).I(userid))."'";
            $row = $mysql->getLine($sql);
            if (!$row){
                $sql = "INSERT INTO `WX_subscribe` (`gameid`,`userid`,`keyid`) VALUES('".I(gameid)."','".I(userid)."','".md5(I(gameid).I(userid))."')";
                $mysql->runSql($sql); 
            }
            echo '1';
       } else {
            $sql = "DELETE FROM `WX_subscribe` WHERE `keyid`='".md5(I(gameid).I(userid))."'";
            $mysql->runSql($sql); 
            echo "1";           
       }


  }    
}
?>